/**
 *====================================================
* 文件名称: InsuranceCoverageBulkstockServiceImpl.java
 * 修订记录：
  * No    日期				作者(操作:具体内容)
  * 1.    2015年12月09日	chenxy(创建:创建文件)
  *====================================================
  * 类描述：(说明未实现或其它不应生成javadoc的内容)
  */
package com.yuexunit.finance.project.service;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Restrictions;

import com.yuexunit.finance.project.entity.InsuranceCoverageBulkstockEntity;
import com.yuexunit.inject.annotation.Implements;
import com.yuexunit.persist.PersistUtil;

/**
 * @ClassName: InsuranceCoverageBulkstockServiceImpl
 * @Description: TODO(这里用一句话描述这个类的作用)
 * @author chenxy
 * @date 2015年12月09日 11:07:15
 */
@Implements(InsuranceCoverageBulkstockService.class)
public class InsuranceCoverageBulkstockServiceImpl implements InsuranceCoverageBulkstockService {

	@Override
	public Long createInsuranceCoverageBulkstock(InsuranceCoverageBulkstockEntity entity) {
		PersistUtil.insert(entity);
		return entity.getCoverageBulkstockId();
	}

	@Override
	public void deleteInsuranceCoverageBulkstock(InsuranceCoverageBulkstockEntity persist) {
		PersistUtil.delete(persist);
	}

	@Override
	public InsuranceCoverageBulkstockEntity inquireInsuranceCoverageBulkstock(Long coverageBulkstockId) {
		return PersistUtil.get(InsuranceCoverageBulkstockEntity.class, coverageBulkstockId);
	}

	@Override
	public List<InsuranceCoverageBulkstockEntity> inquireCoverageBulkstockList(Long insuranceCoverageId) {
		DetachedCriteria criteria = DetachedCriteria.forClass(InsuranceCoverageBulkstockEntity.class);
		criteria.add(Restrictions.eq("insuranceCoverageId", insuranceCoverageId));
		return PersistUtil.get(criteria);
	}

	@Override
	public List<InsuranceCoverageBulkstockEntity> inquireInsuranceCoverageBulkstockList(Long insuranceId) {
		DetachedCriteria criteria = DetachedCriteria.forClass(InsuranceCoverageBulkstockEntity.class);
		criteria.add(Restrictions.eq("insuranceId", insuranceId));
		return PersistUtil.get(criteria);
	}

	@Override
	public List<Long> inquireGroupBulkstockId(Long insuranceCoverageId) {
		DetachedCriteria criteria = DetachedCriteria.forClass(InsuranceCoverageBulkstockEntity.class);
		criteria.add(Restrictions.eq("insuranceCoverageId", insuranceCoverageId));
		criteria.setProjection(Projections.projectionList().add(Projections.groupProperty("bulkstockId")));
		return PersistUtil.get(criteria);
	}

}
